Skip to content

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Oct 5, 2025

The query mir_callgraph_cyclic is supposed to find all callees that may lead to a recursive call back to the given LocalDefId. But that query was built using a function which recurses through the call graph and tries to locally handle hitting the recursion limit during the walk. That is wrong. If the recursion limit is encountered, the set may be incomplete and thus useless. If we hit the recursion limit the only correct thing to do is bail.

Some benchmarks improve because for some functions we will bail out of the call graph walk faster. Some benchmarks regress because we do less inlining, but that is quite rare with the default recursion depth.

This is a possible fix for #131960.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 5, 2025
@saethlin
Copy link
Member Author

saethlin commented Oct 5, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 5, 2025
Make inliner cycle detection a fallible process
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 5, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Oct 5, 2025

☀️ Try build successful (CI)
Build commit: 415a8b5 (415a8b5798d316514c13d80ab58b90dd5ff7785f, parent: 227ac7c3cd486872d5c2352b3df02b571500e53a)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (415a8b5): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.3%, 0.3%] 1
Regressions ❌
(secondary)
0.5% [0.1%, 1.4%] 17
Improvements ✅
(primary)
-1.2% [-2.3%, -0.7%] 4
Improvements ✅
(secondary)
-0.6% [-5.0%, -0.1%] 30
All ❌✅ (primary) -0.9% [-2.3%, 0.3%] 5

Max RSS (memory usage)

Results (primary -4.2%, secondary -3.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.7% [0.9%, 4.8%] 3
Improvements ✅
(primary)
-4.2% [-4.2%, -4.2%] 1
Improvements ✅
(secondary)
-4.3% [-6.6%, -1.7%] 13
All ❌✅ (primary) -4.2% [-4.2%, -4.2%] 1

Cycles

Results (secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.3% [2.1%, 4.3%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-4.8%, -1.1%] 4
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.0%, secondary 0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.3% [0.0%, 1.1%] 4
Regressions ❌
(secondary)
0.5% [0.0%, 1.1%] 2
Improvements ✅
(primary)
-0.1% [-0.3%, -0.0%] 9
Improvements ✅
(secondary)
-0.1% [-0.6%, -0.0%] 14
All ❌✅ (primary) -0.0% [-0.3%, 1.1%] 13

Bootstrap: 470.078s -> 463.689s (-1.36%)
Artifact size: 388.29 MiB -> 387.90 MiB (-0.10%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 5, 2025
@saethlin saethlin force-pushed the fallible-cycle-detection branch from 09c8d23 to fe71247 Compare October 5, 2025 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants